/*
 * $Id: LogRecordWriter.java 161 2013-01-28 11:38:01Z vladimirow@mail.ru $
 * $HeadURL: http://ultralog.googlecode.com/svn/ultralog/trunk/src/java/com/google/code/ultralog/writer/LogRecordWriter.java $
 *
 * This file is a part of ultralog project (http://code.google.com/p/ultralog/).
 * Released under New BSD License.
 */
package com.google.code.ultralog.writer;

import com.google.code.ultralog.utils.CharacterOutputStream;

/**
 * Writes log records into log.
 *
 * @author Mikhail Vladimirov
 */
public interface LogRecordWriter {
    /**
     * Begin writing new log record to log.
     *
     * @param loggerName name of the logger the log record was logged by
     * @param level logging level the record was logged at
     * @param levelName human-readable name of the logging level
     * @return log record
     */
    public LogRecord beginLogRecord (
        String loggerName, int level, String levelName);

    /**
     * Represents log record that can be written to log.
     */
    public interface LogRecord extends CharacterOutputStream
    {
        /**
         * Write log record to log.  Do not use {@link LogRecord} object after
         * calling this method because it can be reused.
         */
        public void write ();

        /**
         * Cancel writing log record.  Do not use {@link LogRecord} object after
         * calling this method because it can be reused.
         */
        public void cancel ();
    }
}
